<template>
  <div class="push-message">
    <step :step-number="stepNumber" />
    <basic v-if="stepNumber === 0" :assets="form" @goNext="nextStep"/>
    <class v-if="stepNumber === 1" :assets="form" @classBack="backStep" @classNext="nextStep"/>
    <detail v-if="stepNumber === 2" :assets="form" @back="backStep"/>
  </div>
</template>

<script>
import Step from './pushmessage/step'
import Basic from './pushmessage/basic'
import Detail from './pushmessage/packagedetail'
import Class from './pushmessage/classdetail'
export default {
  components: {
    Step,
    Basic,
    Detail,
    Class
  },
  props: {
    assets: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      stepNumber: 0,
      form: {
        beFree: '0',
        validityTimeType: 'forever',
        days: 1
      }
    }
  },
  created() {
    if (this.assets.id) {
      this.form = this.assets
    }
  },
  methods: {
    nextStep(val) {
      this.stepNumber++
      this.form = Object.assign({}, val)
    },
    backStep(val) {
      this.stepNumber--
      this.form = Object.assign({}, val)
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
